#include <iostream>
#include <string>
#include <chrono>
#include <thread>
#include <future>
 
using namespace std::chrono;
using namespace std;

string func1(string s) {
    this_thread::sleep_for(seconds(5));
    return s;
}
string func2(string s) {
    this_thread::sleep_for(seconds(5));
    return s;
}
int main() {
    //获取开始时间
    auto start = system_clock::now();
    future<string> res = async(launch::async, func1, "hello");
    string res2 = func2("world");
    string res1 = res.get();
    auto end = system_clock::now();
    auto diff = duration_cast<seconds>(end - start).count();
    cout << "耗时: "<< diff << endl;
    cout << res1 << " " << res2 << endl;
    return 0;
}